/**
 * mk javascript support
 */

if(!md) var md = document;
var mkpop = null;
var li = new Image();
li.src = "imgs/loading_image.gif";
md.itemFileName = "";

// movie management
md.swfID = "swfloader";

// swf postload
function swf_postload(id, sh, swfDir){

	sfPath = sh["swfFileName"];
	if(swfDir) sfPath = swfDir +sfPath;
	if(!sh["align"]) sh["align"] = "";
	if(!sh["quality"]) sh["quality"] = "best";
	if(!sh["bgcolor"]) sh["bgcolor"] = "#FFFFFF";

	shtml = "\n<object type=\"application/x-shockwave-flash\"";
	shtml += "\ndata=\"";
	shtml += sfPath;
	shtml += "\"";
	shtml += "\nwidth=\"";
	shtml += sh["width"];
	shtml += "\"\nheight=\"";
	shtml += sh["height"];
	shtml += "\"\nid=\"";
	shtml += sh["id"];
	shtml += "\"\nalign=\"";
	shtml += sh["align"];
	shtml += "\">";
	shtml += "\n\t<param name=\"movie\" value=\"";
	shtml += sfPath;
	shtml += "\" />\n\t<param name=\"quality\" value=\"";
	shtml += sh["quality"];
	shtml += "\" />\n\t<param name=\"bgcolor\" value=\"";
	shtml += sh["bgcolor"];
	shtml += "\" />";

	if(sh["fv"]){
		var fv = sh["fv"].split(":");
		shtml += "\n\t<param name=\"FlashVars\" value=\"";
		shtml += fv[0] +"=" +fv[1];
		shtml += "\" />";
	}

	if(sh["wmode"]){
		shtml += "\n\t<param name=\"wmode\" value=\"";
		shtml += sh["wmode"];
		shtml += "\" />";
	}

	shtml += "\n</object>";
	//alert(shtml);

	if(!id) return shtml;

	md.getElementById(id).innerHTML = shtml;
}


// set current movie js object
// nstItem is needed by Internet Explorer
// to retrieve movie path in DOM
function set_movie(swfID, nstItem) {

  var swfObj;
  var nstItem = (nstItem) ? nstItem : "swfbox";

  if(navigator.appName.indexOf("Microsoft") !=-1){
	var swfbox = md.getElementById(nstItem);
	swfObj = swfbox.document[swfID];
  }
  else {
	swfObj = document[swfID];
  }

  return swfObj;
}


// ---------------------------------------------------------
// form management - validation


// hilight the button "update these values"
function hilite_swfHeader_bt_update(){
	var bt = md.forms.swfwork.elements.hbt;

	bt.style.color = "#FF6666";
}

// used in main form
function submit_to(opt, swfForm) {

	if(!swfForm) var swfForm = "swfchooser";
	var op = [];
	op["overview"] = 1;
	op["choose"] = 2;
	op["xml"]	 = 3;
	op["backup"] = 4;
	op["new"]	 = 5;
	op["delete"] = 6;

	var sf = md.forms[swfForm];
	sf.elements["at"].value = op[opt];

	if(opt == "new"){

		var defaultSwfName = "untitled.swf";
		var tmpswf = prompt("create new swf with file name: (please avoid strange chars)", defaultSwfName);

		if(!tmpswf.length) tmpswf = defaultSwfName;
		if(tmpswf.indexOf(".swf") == -1) tmpswf = tmpswf + ".swf";

		sf.elements["swf"].value = tmpswf;
	}
	else if(opt == "overview"){

		var sfLength = sf.elements.length;
		for(var j = 0;  j  < sfLength; j++) sf.elements[j].value = "";
		sf.elements.at.value = "1";
	}
	else {
		swf = sf.elements["swf"].value;

		if(!swf.length && opt != "overview"){
				alert("please select an item to proceed");
			return;
		}

		if(opt == "view"){
			mk_swf_pop(swf);
			return;
		}
		else if(opt == "delete"){
			var cresult = confirm("do you really want to delete: " +swf +"?");
			if(!cresult) return;
		}
	}


	sf.submit();
}


// manage max frame number on working swf
function set_maxFrameNumber(maxFrameNumber){ md.maxFrameNumber = maxFrameNumber; }
function restore_maxFrameNumber(formItem){ formItem.value = md.maxFrameNumber; }
function check_maxFrameNumber(formItem){

	var v = parseInt(formItem.value);

	if(isNaN(v) || v > md.maxFrameNumber) restore_maxFrameNumber(formItem);
	if(v < 1) formItem.value = 1;

	md.forms.swfwork.fn.value = formItem.value;

	md.forms.swfwork.submit();
}

// move up and down in timeline
function moveframe(tl){

	var swfwork = md.forms.swfwork;
	var fn = parseInt(swfwork.elements.fn.value);

	if(tl) swfwork.elements.fn.value = ++fn;
	else swfwork.elements.fn.value = --fn;

	check_maxFrameNumber(swfwork.elements.fn);
}


// submit swfwork to select category
function submit_item_category(ic){

	var ics =[];
	ics["swfHeader"] = 10;

	if(ic == ics["swfHeader"]){
	  var validate = validate_swfHeader();
	  if(!validate) return false;
	}


	var swfwork = md.forms.swfwork;
	swfwork.elements.ic.value = ic;
	swfwork.submit();
}

// validate swfwork form header fields
function validate_swfHeader(){

	var swfwork = md.forms.swfwork;
	var result = true;
	var fAr = [];

	var sww = parseInt(swfwork.elements.sww.value);
	var swh = parseInt(swfwork.elements.swh.value);
	var swbg = swfwork.elements.swbg.value;
	var fps = parseInt(swfwork.elements.fps.value);

	fAr["width"] = !isNaN(sww) && (sww >= 18);
	fAr["height"] = !isNaN(swh) && (swh >= 18);
	fAr["fps"] = !isNaN(fps) && (fps < 256);
	fAr["backgroundColor"] = isHex(swbg);
	var str = "please check: ";


	for(var i in fAr) {
		result = result & fAr[i];
		if(!fAr[i]) str+= "\n" + i;
	}

	if(!result) alert(str);
	return result;
}

// validate an hex string
// it MUST be in form of #nnnnnn, obviously valid hex digits
function isHex(hexStr){

  if(hexStr.length != 7) return false; // avoid malformed hexString length
  var hexVals = "0123456789ABCDEF"; // valid hex digits

  hexStr = hexStr.toUpperCase();

  for(var i = 1; i < 7; i++){

  	var hex = hexStr.substring(i, i+1);
  	if(hexVals.indexOf(hex) == -1) return false;
  }

  return true;
}

//-------------------------------------------
// manage table and/or its elements


// sets a function name to use lately
function set_item_viewer(funct, param){
	md.view_funct = funct;
}

// item viewer, it invokes different functions depending of context uses
function item_viewer(param){ eval(md.view_funct +"(" +param +");"); }

function manage_tr(obj, cn, idx, funct){

	if(!funct) var funct = "";

	var current_cn = obj.className;

	if(cn == "trselected"){
		var tbl = md.getElementById("tblIM");
		var t = "";
		var tr = tbl.getElementsByTagName("tr");

		for(var i = 1; i < tr.length; i++){
			tr.item(i).className = "none";
		}
		obj.className = cn;
		//view_image(idx);
		if(idx >= 0 && !funct.length){ item_viewer(idx); }
		else if(funct.length){ eval(funct +"(" +idx +")"); }
	}
	else if(current_cn == "trselected" && cn == "trhover") return;
	else if(current_cn == "trselected" && cn == "none") return;
	else if(current_cn == "trselected" && cn == "trselected") obj.className = "none";
	else obj.className = cn;
}


function set_frameNumber(frameNumber){

	//alert("frameNumber: " +frameNumber);
	md.forms.swfwork.elements.cfn.value = frameNumber;
	md.forms.swfwork.elements.fn.value = frameNumber;
}

// image viewer
function view_image(imgidx){

	var img = new Image();
	var imageFileName = md.imgAr[imgidx]["imgFN"];
	var imgWidth = md.imgAr[imgidx]["imgWidth"];
	var imgHeight = md.imgAr[imgidx]["imgHeight"];
	var wd = imgWidth;
	var hg = imgHeight;
	var imgShown = "100%";
	var scriptPath = "";

	show_loading_image();

	if(imgWidth > 640 || imgHeight > 480){
		wd = Math.round(imgWidth / 4);
		hg = Math.round(imgHeight / 4);
		imgShown = "25%";
	}
	else if (imgWidth > 320 || imgHeight > 240){
		wd = Math.round(imgWidth / 2);
		hg = Math.round(imgHeight / 2);
		imgShown = "50\%";
	}

	scriptPath = "support/mk_unserialize_image.php?act=wi&ifn=" + imageFileName;
	img.src = scriptPath;

	var htmlimg = md.getElementById("imageItem");
	htmlimg.src = img.src;
	htmlimg.width = String(wd);
	htmlimg.height = String(hg);

	var td = md.getElementById("imgZoomDesc");
	td.innerHTML = "zoom at: " + imgShown;
}

function view_swf_shape(swfFileName, frameNumber, itemID){

	var shapeDataStr = swfFileName +",";
	shapeDataStr += frameNumber +",";
	shapeDataStr += itemID;

	//var swfShapeName = swfFileName.substring(0, swfFileName.lastIndexOf("."));
	//swfShapeName += "_" +frameNumber +"_" +itemID +".swf";

	//alert(swfShapeName);

	var swfMovie = set_movie(md.swfID);
	//swfMovie.SetVariable("shapeData", shapeDataStr);
	swfMovie.loadAsset(shapeDataStr);
}


// show a gif to load image
function show_loading_image() {
	var htmlimg = md.getElementById("imageItem");
	li.width = "320";
	li.height = "240";
	htmlimg.width = "320";
	htmlimg.height = "240";
	htmlimg.src = li.src;
}


// start to download image
function download_image(){

	var imgidx = get_image_index();
	var imageFileName = md.imgAr[imgidx]["imgFN"];
	var strURL = "support/mk_unserialize_image.php?act=di&ifn=" + imageFileName;
	location.href = strURL;
}

// start to download alpha image
function download_alpha(){

	var imgidx = get_image_index();
	var imageFileName = md.imgAr[imgidx]["imgFN"];
	var strURL = "support/mk_unserialize_image.php?act=da&ifn=" + imageFileName;
	location.href = strURL;
}

// view alpha image
function view_alpha(){

	var imgidx = get_image_index();

	var img = new Image();
	var imageFileName = md.imgAr[imgidx]["imgFN"];
	var imgWidth = md.imgAr[imgidx]["imgWidth"];
	var imgHeight = md.imgAr[imgidx]["imgHeight"];
	var wd = imgWidth;
	var hg = imgHeight;
	var imgShown = "100%";
	var scriptPath = "";

	show_loading_image();

	if(imgWidth > 640 || imgHeight > 480){
		wd = Math.round(imgWidth / 4);
		hg = Math.round(imgHeight / 4);
		imgShown = "25%";
	}
	else if (imgWidth > 320 || imgHeight > 240){
		wd = Math.round(imgWidth / 2);
		hg = Math.round(imgHeight / 2);
		imgShown = "50\%";
	}

	scriptPath = "support/mk_unserialize_image.php?act=wa&ifn=" + imageFileName;
	img.src = scriptPath;

	var htmlimg = md.getElementById("imageItem");
	htmlimg.src = img.src;
	htmlimg.width = String(wd);
	htmlimg.height = String(hg);

	var td = md.getElementById("imgZoomDesc");
	td.innerHTML = "zoom at: " + imgShown;
}


// retrieve id of image to replace and submit the form
function submit_to_image_replacer_form(){

	var bid = get_image_id();
	var imgidx = get_image_index();
	var imageFileName = md.imgAr[imgidx]["imgFN"];

	if(bid){
		var swfwork = md.forms.swfwork;
		swfwork.elements.sat.value = 1; // IMG_CHOOSE_FOR_REPLACE
		swfwork.elements.iid.value = bid; // img id
		swfwork.elements.pi.value = imageFileName; // img id

		swfwork.submit();
	}
	else alert("please select an image first");
}

// submit the image replace form
// do not confuse with submit_to_image_replacer_form, that is the image_replacer entry
function submit_to_image_replacer_action(){

	var swfwork = md.forms.swfwork;

	var bid = get_image_id();
	var imgidx = get_image_index();
	var imageFileName = md.imgAr[imgidx]["imgFN"];
	var imgWidth = md.imgAr[imgidx].imgWidth;
	var imgHeight = md.imgAr[imgidx].imgHeight;

	swfwork.elements.sat.value = 2; // IMG_REPLACE
	swfwork.elements.pi.value = imageFileName; // img filename that will be used to replace

	var fiWidth = md.getElementById("fiWidth").innerHTML;
	var fiHeight = md.getElementById("fiHeight").innerHTML;

	var cfirm = true;

	if(imgWidth != fiWidth || imgHeight != fiHeight){

		var strcFirm = "you are near to replace an image with different ";
		strcFirm += "width and/or height, do I have to continue?";
		cfirm = confirm(strcFirm);
	}

	if(cfirm) swfwork.submit();
	else return;
}


// retrieve image index if an image is selected
function get_image_id(tblID){

	var tbl = md.getElementById( (!tblID) ? "tblIM" : tblID );
	var tr = tbl.getElementsByTagName("tr");

	for(var i = 1; i < tr.length; i++){

		var td = tr.item(i).getElementsByTagName("td");

		if(tr.item(i).className == "trselected"){
			return td.item(0).innerHTML;
		}
	}
	return false; // item not found
}


// retrieve image table data, return an associative array
function get_image_stat(tblID){

	var tbl = md.getElementById( (!tblID) ? "tblIM" : tblID );
	var tr = tbl.getElementsByTagName("tr");
	var imgStat = new Object();

	imgStat.imgFN = "";
	imgStat.imgWidth = "";
	imgStat.imgHeight = "";

	var props = 3;

	for(var i = 1; i < tr.length; i++){

		var td = tr.item(i).getElementsByTagName("td");

		if(tr.item(i).className == "trselected"){

			var k = 0;
			for(var j in imgStat){

				var sh = td.item(j).innerHTML;
				var shlc = sh.toLowerCase();
				var sp = td.item(k).getElementsByTagName("span");

				if(!sp)	imgStat[j] = td.item(k).innerHTML;
				else imgStat[j] = sp.item(0).innerHTML;

				k++;
			}

			return imgStat;
		}
	}
	return false; // item not found
}


// retrieve imag index if an image is selected
function get_image_index(tblID){

	var tbl = md.getElementById( (!tblID) ? "tblIM" : tblID );
	var tr = tbl.getElementsByTagName("tr");

	for(var i = 1; i < tr.length; i++){
		if(tr.item(i).className == "trselected") return i - 1;
	}
	return false;
}


// start to download alpha image
function download_shape(){

	if(!md.itemFileName.length) return;
	var strURL = "support/mk_download_swf.php?swf=" + md.itemFileName;
	location.href = strURL;
}


// generic pop-up
function popthis(wd, hg, strURL){

   var feat = "top=100,left=100,width=" + wd + ",height=" + hg;
   if(md.oWin && !md.oWin.closed) md.oWin.close();
   md.oWin = window.open(strURL, "", feat);
}


// open a pop-up to show an swf file
// using a nice "elastic" effect
function mk_swf_pop(swf) {

	var strURL = "support/mk_swf_pop.php?popswf=" +swf;
	if(mkpop && !mkpop.closed) mkpop.close();
	window.open(strURL, "", "left=100,top=100, width=100,height=100");
}

// elastic pop - a nice pop-up effect
// 10.2k4
// jaco@pixeldump
var myT = null;
var wi = 100;
var hi = 100;
var wdiff = 0;
var hdiff = 0;

var d = 40;
var wdAr = [];
var hgAr = [];
var stepCount = 0;
var swf = "";
var bgCol = "#FFFFFF";

// thx to mr. Penner www.robertpenner.com
function Math_easeOutExpo(t,b,c,d){
	return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b;
}


function expando(w, h, path_to_swf, bgColor){

	wd = w;
	hg = h;
	wdiff = wd - wi;
	hdiff = hg - hi;
	swf = path_to_swf;
	if(bgColor) bgCol = bgColor;

	for(var i = 1; i <= d; i++){
		wdAr[wdAr.length] = Math_easeOutExpo(i, wi, wdiff, d);
		hgAr[hgAr.length] = Math_easeOutExpo(i, hi, hdiff, d);
	}

	//alert(hgAr.toString());

	myT = setInterval("stepExpand()", 50);
}

function stepExpand(){

	if(stepCount++ >= d - 1){
		clearInterval(myT);

		var sHtml = "<html><head><title>";
		sHtml += swf;
		sHtml += "</title>";
		sHtml += "<style type=\"text/css\">";
		sHtml += "<!--";
		sHtml += "body {";
		sHtml += " margin-left: 0px;";
		sHtml += " margin-top: 0px;";
		sHtml += " margin-right: 0px;";
		sHtml += " margin-bottom: 0px;";
		sHtml += " backgroundColor: ";
		sHtml += bgCol;
		sHtml += ";\n}\n -->\n </style>";

		sHtml += "</head><body>";

		sHtml += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
		sHtml += " codebase=\"http" +"://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"";
		sHtml += " WIDTH=\"";
		sHtml += wd;
		sHtml += "\" HEIGHT=\"";
		sHtml += hg;
		sHtml += "\" id=\"";
		sHtml += "prova";
		sHtml += "\" ALIGN=\"\">";
		sHtml += " <PARAM NAME=movie VALUE=\"";
		sHtml += swf;
		sHtml += "\"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE="
		sHtml += bgCol;
		sHtml += "> <EMBED src=\"";
		sHtml += swf;
		sHtml += "\" quality=high bgcolor=";
		sHtml += bgCol;
		sHtml += "  WIDTH=\"";
		sHtml += wd;
		sHtml += "\" HEIGHT=\"";
		sHtml += hg;
		sHtml += "\" NAME=\"";
		sHtml += "prova";
		sHtml += "\" ALIGN=\"\"";
		sHtml += " TYPE=\"application/x-shockwave-flash\"";
		sHtml += " PLUGINSPAGE=\"http" + "://www" + ".macromedia.com/go/getflashplayer\"></EMBED></OBJECT>";
		sHtml += "";
		sHtml += "</body></html>\"";

		document.open("text/replace");
		document.write(sHtml);
		document.close();

		return;
	}
	self.resizeTo(wdAr[stepCount], hgAr[stepCount]);
}


//
function view_image_item (idx){

	var img = new Image();
	var imageFileName = md.imgAr[idx]["imgFN"];
	var imgWidth = md.imgAr[idx]["imgWidth"];
	var imgHeight = md.imgAr[idx]["imgHeight"];
	var wd = imgWidth;
	var hg = imgHeight;
	var imgShown = "100%";
	//var scriptPath = "";

	show_loading_image();

	if(imgWidth > 640 || imgHeight > 480){
		wd = Math.round(imgWidth / 4);
		hg = Math.round(imgHeight / 4);
		imgShown = "25%";
	}
	else if (imgWidth > 320 || imgHeight > 240){
		wd = Math.round(imgWidth / 2);
		hg = Math.round(imgHeight / 2);
		imgShown = "50\%";
	}

	scriptPath = "imgs/" + imageFileName;
	img.src = scriptPath;

	var htmlimg = md.getElementById("imageItem");
	htmlimg.src = img.src;
	htmlimg.width = String(wd);
	htmlimg.height = String(hg);

	var s = md.getElementById("imgZoomDesc");
	s.innerHTML = ", zoom at: " + imgShown;
}


// image 2 swf js
//
function view_image2swf_item (idx){

	var img = new Image();
	var imageFileName = md.imgAr[idx]["imgFN"];
	var imgWidth = md.imgAr[idx]["imgWidth"];
	var imgHeight = md.imgAr[idx]["imgHeight"];
	var wd = imgWidth;
	var hg = imgHeight;
	var imgShown = "100%";
	var scriptPath = "";

	show_loading_image();

	if(imgWidth > 640 || imgHeight > 480){
		wd = Math.round(imgWidth / 4);
		hg = Math.round(imgHeight / 4);
		imgShown = "25%";
	}
	else if (imgWidth > 320 || imgHeight > 240){
		wd = Math.round(imgWidth / 2);
		hg = Math.round(imgHeight / 2);
		imgShown = "50\%";
	}

	scriptPath = "imgs/" + imageFileName;
	img.src = scriptPath;
	loadswf(idx);

	var htmlimg = md.getElementById("imageItem");
	htmlimg.src = img.src;
	htmlimg.width = String(wd);
	htmlimg.height = String(hg);

	var td = md.getElementById("imgZoomDesc");
	td.innerHTML = "zoom at: " + imgShown;
}


function loadswf(idx){

	var swfMovie = set_movie(md.swfID);
	swfMovie.SetVariable("imageFileName", md.imgAr[idx]["imgFN"]);
}

function download_swf(){

	var imgidx = get_image_index();
	var imageFileName = md.imgAr[imgidx]["imgFN"];
	var strURL = "support/mk_download_swf.php?img=" + imageFileName;
	location.href = strURL;
}


// mk cms js
//

function set_current_swfFileName(swfFileName){

	md.swfFileName = swfFileName;

	var sf = md.forms.swfchooser; // set the swf to work

	sf.elements.swf.value = swfFileName;
}

function get_current_swfFileName(){
	return md.swfFileName;
}

function load_swf_params(idx){

	var swfID = "swf_overview_loader";
	var swfObj = set_movie(swfID, "swflo");
	var swfFileName = md.swfAr[idx];

    set_current_swfFileName(swfFileName);
	swfObj.SetVariable("swfFileName", swfFileName);
}

function show_swf(str){

  //alert(str);
  var swfHeader = new Object();
  var myParams = str.split(",");
  var mLength = myParams.length;

  for(var i = 0; i < mLength; i++){
  	var prop = myParams[i].split(":");
    swfHeader[prop[0]] = prop[1];
  }

	//var b = "";
	//for(var i in swfHeader) b += "\t" + i + ": " + swfHeader[i];
	//alert(b);

  render_swf_box(swfHeader, "blankdiv");
}

function set_available_item(itemFileName){
	//alert(itemFileName);
	md.itemFileName = itemFileName;
}

function render_swf_box(swfHeader, strDiv){

	var wd = parseInt(swfHeader["width"]);
	var hg = parseInt(swfHeader["height"]);
	var rnd = Math.round(Math.random() * 10000000);

	if(wd > 640 || hg > 480){
	  wd = Math.round(wd / 4);
	  hg = Math.round(hg / 4);
	}
	else if (wd > 320 || hg > 240){
	  wd = Math.round(wd / 2);
	  hg = Math.round(hg / 2);
	}

    //var swfPath = "media/flash/" + swfHeader["swfFN"];
    var bdiv = md.getElementById(strDiv);
    //var id = "a";

	swfHeader["width"] = wd;
	swfHeader["height"] = hg;
	swfHeader["id"] = "a" +rnd;
	swfHeader["swfFileName"] += "?a=" +rnd;

    var shtml = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" height=\"100%\">";
    shtml += "\n<tr><td>";

	shtml += swf_postload(null, swfHeader, "media/flash/");

    //shtml += "\n<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
    //shtml += "\ncodebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"";
    //shtml += "\nWIDTH=\"";
    //shtml += wd;
    //shtml += "\"\nHEIGHT=\"";
    //shtml += hg;
    //shtml += "\"\nid=\"";
    //shtml += id;
    //shtml += "\"\nALIGN=\"\">\n\t<PARAM NAME=movie VALUE=\"";
    //shtml += swfPath;
    //shtml += "?a=" + rnd;
    //shtml += "\" />\n\t<PARAM NAME=quality VALUE=\"high\" />\n\t<PARAM NAME=\"bgcolor\" VALUE=\"";
    //shtml += swfHeader["bgcol"];
    //shtml += "\" />\n\t<param name=\"allowScriptAccess\" VALUE=\"sameDomain\" />";
    //shtml += "\n\t\t<EMBED src=\"";
    //shtml += swfPath;
    //shtml += "?a=" + rnd;
    //shtml += "\"\n\t\tquality=\"high\"\n\t\t bgcolor=\"";
    //shtml += swfHeader["bgcol"];
    //shtml += "\"\n\t\tWIDTH=\"";
    //shtml += wd;
    //shtml += "\"\n\t\tHEIGHT=\"";
    //shtml += hg;
    //shtml += "\"\n\t\tNAME=\"";
    //shtml += id;
    //shtml += "\"\n\t\tALIGN=\"\"";
    //shtml += "\n\t\tallowScriptAccess=\"sameDomain\"";
    //shtml += "\n\t\tTYPE=\"application/x-shockwave-flash\";";
    //shtml += "\n\t\tswLiveConnect=\"true\"";
    //shtml += "\n\t\tPLUGINSPAGE=";
    //shtml += "\"http://www.macromedia.com/go/getflashplayer\" />\n</EMBED>\n</OBJECT>";
    shtml += "\n</td></tr></table>";

    bdiv.innerHTML = shtml;
}

function toggle_progressbar(val){

	var swfObj = set_movie("pbapp", "swflo");
	swfObj.SetVariable("wo", val);
}

/**
 *
 */
function swf_view_disassemble(idx){

	toggle_progressbar(10);
	//load_swf_params(idx);
	var swfFileName = md.swfAr[idx];
	set_current_swfFileName(swfFileName);
	var sf = md.forms.swfchooser;
	sf.elements.act.value = "disassemble";
	sf.elements.swf.value = md.swfFileName;
	//alert(sf.elements.swf.value);
	var params = {};
	params.act = "disassemble";
	params.swf = md.swfFileName;
	do_ajax_command(params);
}


function validate_mft_form(){

	var swfupl = md.forms.swf_upl;
	var swffile = swfupl.elements.swffile.value;
	var ext = swffile.substr(-4).toLowerCase();

	if(ext != ".swf"){
		alert("only swf file may be loaded, please select a swf file");
		return false;
	}

	swfupl.submit();
}
// -----------------------------------------